package info.liuxing.okhttp.interceptor;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.IOException;

/**
 * CustomNetworkInterceptor
 *
 * @author liuxing (SE)
 * @summary CustomNetworkInterceptor
 * @Copyright (c) 2017, Lianjia Group All Rights Reserved.
 * @since 2017-11-30 16:14
 */
public class CustomNetworkInterceptor implements Interceptor {

    private static final Logger LOGGER = LoggerFactory.getLogger(CustomNetworkInterceptor.class);

    @Override
    public Response intercept(Chain chain) throws IOException {
        Request request = chain.request();

        LOGGER.debug("发送请求: [{}] {}\n{}", request.url(), chain.connection(), request.headers());

        return chain.proceed(request);
    }
}